﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>文件上传</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="scripts/boot.js" type="text/javascript"></script>
    

    <style type="text/css">
    html, body
    {        
        padding:0;
        margin:0;
        border:0;
        height:100%;
        overflow:hidden;
    }

    .container {
        width: 100%;
        height: 100%;
        display: flex; justify-content: center; align-items: center;
    }
    </style>
</head>
<body>

<div class="container">
    <div style="width: 100%; text-align: center;">
        <form id="form1" method="post">
            <div style="padding-left:11px;padding-bottom:5px;">
                <input id="fileupload1" class="mini-fileupload" name="file" style="width: 300px;"
                       limitType="*.xls,xlsx"
                       onuploadsuccess="onUploadSuccess"
                       onuploaderror="onUploadError"
                       onfileselect="onFileSelect"
                       required="true"
                />
            </div>
            <div style="text-align:center;padding:40px;">
                <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>
                <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>
            </div>
        </form>
    </div>
</div>

    <script type="text/javascript">
        mini.parse();
        var isClick = false; // 防止按钮重复点击

        // 动态设置url
        var fileupload = mini.get("fileupload1");
        fileupload.setUploadUrl("/sign/bus/file/indent/upload");

        function onFileSelect(e) {
            // alert("选择文件");
        }
        function onUploadSuccess(e) {
            // console.log(e.serverData);
            this.setText("");
            alert("导入成功");
            CloseWindow("close");
        }
        function onUploadError(e) {
            // console.log(e);
            // alert("导入失败：错误信息：" + e.serverData);
        }

        function startUpload() {
            if(fileupload.value) {
                if(isClick) {
                    alert("系统正在处理，请稍候 ...");
                    return;
                }
                isClick = true;
                fileupload.startUpload();
            } else {
                alert("请选择文件！");
            }
        }

        function SetData(data) {

        }

        function CloseWindow(action) {
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();            
        }

        function onOk(e) {
            startUpload();
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }
        //////////////////////////////////


    </script>
</body>
</html>
